Bug 538362 - Get Win32 icons back in the file chooser
authorTor Lillqvist <tml@novell.com>
Mon, 16 Jun 2008 13:27:46 +0000 (13:27 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 16 Jun 2008 13:27:46 +0000 (13:27 +0000)
2008-06-16  Tor Lillqvist  <tml@novell.com>

Bug 538362 - Get Win32 icons back in the file chooser

* gtk/gtkicontheme.c (choose_icon): Check if the icon name is a
reference to an icon resource in a DLL or .EXE as in the
Registry. In that case, extract the icon and convert to a
GdkPixbuf. Patch by Hans Breuer.

svn path=/trunk/; revision=20398

ChangeLog
gtk/gtkicontheme.c

index a819e981f78b1ff56fbfa1f8cf1a365929d3ccf6..ec7495dbc5bde22e334b757e997972800f57dcda 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-06-16  Tor Lillqvist  <tml@novell.com>
+
+       Bug 538362 - Get Win32 icons back in the file chooser
+
+       * gtk/gtkicontheme.c (choose_icon): Check if the icon name is a
+       reference to an icon resource in a DLL or .EXE as in the
+       Registry. In that case, extract the icon and convert to a
+       GdkPixbuf. Patch by Hans Breuer.
+
 2008-06-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/stock-icons/24/audio-volume*: Add icons used by GtkVolumeButton
index 78696483da8f0318fe040b9c894fde599dae4b9f..43666a4c2a87056d15e6cc9e69f89064898bcba1 100644 (file)
@@ -33,6 +33,9 @@
 #ifndef S_ISDIR
 #define S_ISDIR(mode) ((mode)&_S_IFDIR)
 #endif
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+#include "win32/gdkwin32.h"
 #endif /* G_OS_WIN32 */
 
 #include "gtkicontheme.h"
@@ -1277,6 +1280,32 @@ choose_icon (GtkIconTheme       *icon_theme,
       if (unthemed_icon)
         break;
     }
+#ifdef G_OS_WIN32
+  /* Still not found an icon, check if reference to a Win32 resource */
+  if (!unthemed_icon)
+    {
+      gchar **resources;
+      HICON hIcon = NULL;
+      
+      resources = g_strsplit (icon_names[0], ",", 0);
+      if (resources[0])
+       {
+         wchar_t *wfile = g_utf8_to_utf16 (resources[0], -1, NULL, NULL, NULL);
+         ExtractIconExW (wfile, resources[1] ? atoi (resources[1]) : 0, &hIcon, NULL, 1);
+         g_free (wfile);
+       }
+      
+      if (hIcon)
+       {
+         icon_info = icon_info_new ();
+         icon_info->cache_pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon);
+         DestroyIcon (hIcon);
+          icon_info->dir_type = ICON_THEME_DIR_UNTHEMED;
+          icon_info->dir_size = size;
+       }
+      g_strfreev (resources);
+    }
+#endif
 
   if (unthemed_icon)
     {
@@ -1327,6 +1356,7 @@ choose_icon (GtkIconTheme       *icon_theme,
              found = g_file_test (default_theme_path, G_FILE_TEST_IS_REGULAR);
              g_free (default_theme_path);
            }
+
          if (!found)
            {
              g_warning (_("Could not find the icon '%s'. The '%s' theme\n"